<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="/Views/Admin/css/themes/default/easyui.css" />
<link rel="stylesheet" href="/Views/Admin/css/themes/icon.css">
<script type="text/javascript" src="/Views/Admin/js/jquery.min.js"></script>
<script type="text/javascript"
	src="/Views/Admin/js/jquery.easyui.min.js"></script>
</head>

<body>
	<table id="dg" title="试题大类信息" class="easyui-datagrid"
		style="width: 100%; height: 400px" url="/exam/sendSTDL"
		toolbar="#toolbar" rownumbers="true" fitColumns="true"
		singleSelect="true">
		<thead>
			<tr>
				<th field="NAME" width="200">试题大类名称</th>
				<th field="NOTE" width="200">备注</th>
			</tr>
		</thead>
	</table>
	<div id="toolbar">
		<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"
			onclick="newSTDL()">  新  增  </a> <a href="#"
			class="easyui-linkbutton" iconCls="icon-edit" plain="true"
			onclick="editSTDL()">  编  辑  </a> <a href="#"
			class="easyui-linkbutton" iconCls="icon-remove" plain="true"
			onclick="destroySTDL()">  删  除  </a>
	</div>
	<!-- 表格对话框-->
	<div id="dlg" class="easyui-dialog"
		style="width: 400px; height: 280px; padding: 10px 20px" closed="true"
		buttons="#dlg-buttons">
		<div class="ftitle">试题大类信息</div>
		<form id="fm" method="post">
			<div class="fitem">
				<label>名  称:</label> <input name="NAME"
					class="easyui-validatebox" required="true">
			</div>
			<div class="fitem">
				<label>备  注:</label> <input name="NOTE"
					class="easyui-validatebox" required="true">
			</div>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok"
			onclick="saveSTDL()">Save</a> <a href="#" class="easyui-linkbutton"
			iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
	</div>




	<div id="dlg" class="easyui-dialog"
		style="width: 400px; height: 280px; padding: 100px 200px" closed="true"
		buttons="#dlg-buttons">
		<div class="ftitle">试题大类信息</div>
		<form id="fm" method="post">
		    <div class="fitem">
				<label>名  称:</label> <input name="NAME"
					class="easyui-validatebox" required="true">
			</div>
			<div class="fitem">
				<label>备  注:</label> <input name="NOTE"
					class="easyui-validatebox" required="true">
			</div>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok"
			onclick="saveSTDL()">Save</a> <a href="#" class="easyui-linkbutton"
			iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
	</div>


	<script type="text/javascript">
	function newSTDL(){
		$('#dlg').dialog('open').dialog('setTitle','新增试题大类');
		$('#fm').form('clear');
		url = '/exam/addSTDL';
	}
	
	
	

	
	function editSTDL(){
		var row = $('#dg').datagrid('getSelected');
		if (row){
			$('#dlg').dialog('open').dialog('setTitle','编辑试题大类');
			$('#fm').form('load',row);
			url = '/exam/editSTDL?id='+row.ID;
		}
	}
	
	function saveSTDL(){
		$('#fm').form('submit',{
			url: url,
			onSubmit: function(){
				return $(this).form('validate');
			},
			success: function(result){
				var result = eval('('+result+')');
				if (result.errorMsg){
					$.messager.show({
						title: 'Error',
						msg: result.errorMsg
					});
				} else {
					$('#dlg').dialog('close');		// close the dialog
					$('#dg').datagrid('reload');	// reload the user data
				}
			}
		});
	}
	
	
	
	function destroySTDL(){
		var row = $('#dg').datagrid('getSelected');
		if (row){
			$.messager.confirm('Confirm','你确定删除这条信息吗？',function(r){
				if (r){
					$.post('/exam/delSTDL',{id:row.ID},function(result){
						if (result.success){
							$('#dg').datagrid('reload');
						} else {
							$.messager.show({	// show error message
								title: 'Error',
								msg: result.errorMsg
							});
						}
					},'json');
				}
			});
		}
	}
	</script>
</body>

</html>